#_*_coding:utf-8_*_
__author__ = 'alex'
name2 = "alex"
'''
def sayhi(n,age, salary,job="IT",):
    #print name2
    global name2
    global name3 #not suggested
    name2 = 23
    name3 = 'ttst'
    n = "Jack"
    print "my name is:"
    print "my age is:",age
    print "my job is:",job



def multiply(x,y):
    if x> y :
        return x/y
        print "--------"
    else:
        return x*y

res = multiply(5,8)

if res >30:
    print "===do sth...."
else:
    print "do else..."

def sayhi(*args):
    print args
def sayhi2(**kwargs):
    print kwargs
    if kwargs.has_key("name"):
        print kwargs['name']
    else:
        print " must input name arg"
sayhi('arg1','g2','g3')

sayhi2(name="alex",age=30,job='IT')

#lambda 函数
dic1 = {9:2,
        4:3,
        6:9,
        'a':'test',
        'e':'fff',
        '*': '$'}
print dic1.items()
def f(x):
    return x**2
g= lambda x:x**2
#g(4) # f(4)
#print g(4)
print map(lambda x:x**2,range(10))
print sorted(dic1.items(), key=lambda x:x[1])
'''

#迭代
import time
def run():
    '''
    print "test 1"
    yield 1
    time.sleep(1)
    print "test 2"
    yield 2
    time.sleep(1)
    print "test 3"
    yield 3
    time.sleep(1)
    print "test 4"
    '''
    for i in range(100):
        print '-->',i
        yield  i

task = run()
task.next()
print '-----do sth else----'
task.next()
print '-----do sth else----'
task.next()
print '-----do sth else----'
task.next()
task.next()